home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / e / ddmoduls.lha / dd_Modules / dd_gui / dd_windowcontrol.e < prev    next >
Text File  |  1995-12-01  |  3KB  |  110 lines

  1. ->
  2. -> dd_windowcontrol.e - window control class
  3. ->
  4. -> Copyrights © 1995 by Leon `LikeWise' Woestenberg, Digital Disturbance.
  5. -> All Rights Reserved
  6. ->
  7. -> FOLDER opts
  8. OPT MODULE
  9. -> ENDFOLDER
  10. -> FOLDER modules
  11. MODULE 'intuition/intuition'
  12. MODULE '*dd_busypointer'
  13. -> ENDFOLDER
  14. -> FOLDER classes
  15. -> window control class definition
  16. EXPORT OBJECT dd_windowcontrol
  17.   PRIVATE
  18.   window:PTR TO window
  19.   idcmpflags:LONG
  20.   disablecount:LONG
  21.   blockrequester:PTR TO requester
  22.   busypointer:PTR TO busypointer
  23. ENDOBJECT
  24. -> ENDFOLDER
  25.  
  26. -> FOLDER new
  27. -> constructor
  28. EXPORT PROC new(window=NIL) OF dd_windowcontrol
  29.   -> Remember the window this object must act on.
  30.   self.window:=window
  31.   -> Counter to keep the number of nested disable calls.
  32.   self.disablecount:=0
  33.   -> Get ourselves a busypointer object.
  34.   NEW self.busypointer.new(self.window)
  35. ENDPROC
  36. -> ENDFOLDER
  37. -> FOLDER end
  38. -> destructor
  39. EXPORT PROC end() OF dd_windowcontrol
  40.   -> If the program exits prematurely, we call enable here for each
  41.   -> outstanding disable call. This should never occur (!).
  42.   WHILE self.disablecount DO self.enable()
  43.   END self.busypointer
  44. ENDPROC
  45. -> ENDFOLDER
  46. -> FOLDER disable
  47. EXPORT PROC disable(disableidcmpflags=IDCMP_REFRESHWINDOW) OF dd_windowcontrol
  48.   -> Only act if this is a valid instance. This makes it safe to invoke
  49.   -> this method on a NIL pointer.
  50.   IF self
  51.  
  52.     -> valid window?
  53.     IF self.window
  54.  
  55.       -> We keep a disable count, to allow nested calls.
  56.       self.disablecount:=self.disablecount+1
  57.       -> We only have to act if the window first enters busy state, i.e. when
  58.       -> the count becomes 1. If the count was higher, the window already is
  59.       -> in disabled state, and we just skip.
  60.       IF self.disablecount=1
  61.  
  62.         -> Remember the IDCMP flags of the enabled window.
  63.         self.idcmpflags:=self.window.idcmpflags
  64.         -> Now clear some IDCMP flags.
  65.         ModifyIDCMP(self.window,disableidcmpflags AND self.idcmpflags)
  66.  
  67.         -> Attach an invisible requester, that blocks user input.
  68.         InitRequester(NEW self.blockrequester)
  69.         Request(self.blockrequester,self.window)
  70.  
  71.         -> Put the busypointer object into busy state.
  72.         self.busypointer.busy()
  73.       ENDIF
  74.     ENDIF
  75.   ENDIF
  76. ENDPROC
  77. -> ENDFOLDERER
  78. -> FOLDER enable
  79. EXPORT PROC enable() OF dd_windowcontrol
  80.  
  81.   -> Only act if this is a valid instance. This makes it safe to invoke
  82.   -> this method on a NIL pointer.
  83.   IF self
  84.  
  85.     -> valid window?
  86.     IF self.window
  87.  
  88.       -> We decrease the disable count by one. If this window is going into
  89.       -> disable state now, we act. Otherwise, the window still has a nested
  90.       -> disable call pending.
  91.       self.disablecount:=self.disablecount-1
  92.       IF self.disablecount=0
  93.  
  94.         -> Get busypointer object out of busy state.
  95.         self.busypointer.unbusy()
  96.  
  97.         -> We detach the block requester.
  98.         EndRequest(self.blockrequester,self.window)
  99.         END self.blockrequester
  100.  
  101.         -> Restore the IDCMP flags to those prior to disable.
  102.         ModifyIDCMP(self.window,self.idcmpflags)
  103.  
  104.       ENDIF
  105.     ENDIF
  106.   ENDIF
  107. ENDPROC
  108. -> ENDFOLDER
  109.  
  110.